<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>element使用</title>
  <script src="../js/vue.js"></script>
  <script src="../js/axios.js"></script>
  <!-- 引入样式 -->
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <!-- 引入组件库 -->
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>

<body>
  <div id="app">
    <!-- 表格 -->
    <el-table :data="tableData" style="width: 100%">
      <el-table-column type="index" width="50"></el-table-column>
      <el-table-column prop="name" label="栏目名称" width="180"></el-table-column>
      <el-table-column prop="description" label="栏目描述" width="180"></el-table-column>
      <el-table-column prop="parentId" label="所属栏目" width="180"></el-table-column>
    </el-table>
  </div>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        tableData: []
      },
      methods: {
        async findAllCategories() {
          axios.defaults.baseURL = 'http://47.94.46.113:8888';
          let result = await axios({
            url: '/index/category/findAll',
            methods: 'get'
          })
          this.tableData = result.data.data;
        }
      },
      created() {
        this.findAllCategories();
      }
    })
  </script>
</body>

</html>